From: Fred Pierresteguy Date: Fri, 18 Feb 1994 13:24:41 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~93068 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=0b96f00bb4b192ddb350ba1326c6b87bd67b5e93;p=emacs.git *** empty log message *** --- diff --git a/lwlib/lwlib-Xlw.c b/lwlib/lwlib-Xlw.c index c48d6614b28..e07ee19c7bf 100644 --- a/lwlib/lwlib-Xlw.c +++ b/lwlib/lwlib-Xlw.c @@ -71,13 +71,14 @@ pick_hook (w, client_data, call_data) } /* creation functions */ + static Widget xlw_create_menubar (instance) widget_instance* instance; { Widget widget; - widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); + widget_value *tem = malloc_widget_value (); /* _XtCreate is freeing the object we passed, so make a copy that we free later. */ @@ -89,7 +90,7 @@ xlw_create_menubar (instance) XtNmenu, tem, 0); - XtFree (tem); + free_widget_value (tem); XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); @@ -106,7 +107,7 @@ xlw_create_popup_menu (instance) Widget widget; - widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); + widget_value *tem = malloc_widget_value (); /* _XtCreate is freeing the object we passed, so make a copy that we free later. */ @@ -119,7 +120,7 @@ xlw_create_popup_menu (instance) XtNhorizontal, False, 0); - XtFree (tem); + free_widget_value (tem); XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c index e6af711e697..c2f2f05cba5 100644 --- a/lwlib/lwlib.c +++ b/lwlib/lwlib.c @@ -112,6 +112,8 @@ safe_free_str (s) } static widget_value *widget_value_free_list = 0; +static int malloc_cpt = 0; +static int malloc_cpt_id = 0; widget_value * malloc_widget_value () @@ -126,6 +128,7 @@ malloc_widget_value () else { wv = (widget_value *) malloc (sizeof (widget_value)); + malloc_cpt++; } memset (wv, 0, sizeof (widget_value)); return wv; @@ -140,8 +143,24 @@ free_widget_value (wv) { if (wv->free_list) abort (); - wv->free_list = widget_value_free_list; - widget_value_free_list = wv; + + if (malloc_cpt > 20) + { + /* When the number of already allocated cells is too big, + We free it. */ + malloc_cpt_id++; + free (wv); + if (malloc_cpt_id > 20) + { + malloc_cpt_id = 0; + malloc_cpt = 0; + } + } + else + { + wv->free_list = widget_value_free_list; + widget_value_free_list = wv; + } } static void